package zhangcong.controller;

import zhangcong.entity.BjEntity;
import zhangcong.entity.Page;
import zhangcong.entity.PageUtils;
import zhangcong.entity.ZhangCongEntity;
import zhangcong.service.ZhangCongService;

import javax.annotation.Resource;
import java.util.List;
////
public class ZhangCongController {

    ZhangCongEntity zhangCongEntity=null;
    String name = null;
    Integer pageNo = null;
    Page page =  null;
    List<BjEntity> bjEntity=null;
    String flag = "0";
    @Resource
    ZhangCongService zhangCservice;

    public String login(){
        flag = zhangCservice.login(zhangCongEntity);
        return "save";
    }


    public String queryPage(){
        int totalCount= zhangCservice.queryCount(name);
        page = PageUtils.getPage(5,totalCount,pageNo);
        List<ZhangCongEntity> list = zhangCservice.queryPage(page,name);
        page.setData(list);
      return "queryPage";
    }

    public String save(){
        zhangCservice.save(zhangCongEntity);
        flag = "1";
        return "save";
    }
    public String del(){
        zhangCservice.del(zhangCongEntity);
        flag = "1";
        return "save";
    }

    public String edit(){
        zhangCongEntity =zhangCservice.edit(zhangCongEntity);

        return "edit";
    }

    public String bj(){
        bjEntity =zhangCservice.bj();
        return "bj";
    }


    //@Resource @Autowired 作用相同 去spring容器中到bean实例
    //@Service @Component 向spring 容器中放入bean（类的对象）实例


    public List<BjEntity> getBjEntity() {
        return bjEntity;
    }

    public void setBjEntity(List<BjEntity> bjEntity) {
        this.bjEntity = bjEntity;
    }

    public ZhangCongEntity getZhangCongEntity() {
        return zhangCongEntity;
    }

    public void setZhangCongEntity(ZhangCongEntity zhangCongEntity) {
        this.zhangCongEntity = zhangCongEntity;
    }

    public ZhangCongService getZhangCservice() {
        return zhangCservice;
    }

    public void setZhangCservice(ZhangCongService zhangCservice) {
        this.zhangCservice = zhangCservice;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }
}
